home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / show.c < prev    next >
Text File  |  1993-06-10  |  4KB  |  146 lines

  1.  
  2.  
  3.        /***********************************************
  4.        *
  5.        *   file d:\cips\show.c
  6.        *
  7.        *   Functions: This file contains
  8.        *      main
  9.        *
  10.        *   Purpose:
  11.        *      This is the main routine of a
  12.        *      stand alone program that displays
  13.        *      TIFF images.
  14.        *
  15.        *      You can run this program using either
  16.        *      the command line or via menus.
  17.        *
  18.        *      show image-name [help -i -h -il -ie -t]
  19.        *
  20.        *      show help - gives you a usage message
  21.        *
  22.        *      show - gives you the menu interface
  23.        *
  24.        *      show image-name - displays that image
  25.        *
  26.        *      Options:
  27.        *         -i  - invert the image when displaying
  28.        *         -h  - show the histogram
  29.        *         -il - specify initial line
  30.        *         -ie - specify initial element
  31.        *         -t  - means the words following -t
  32.        *               are a title to display below
  33.        *               the image.  Always put the -t
  34.        *               as the final option.
  35.        *
  36.        *   External Calls:
  37.        *      gin.c - get_image_name
  38.        *      rtiff.c - read_tiff_image
  39.        *      tiff.c - read_tiff_header
  40.        *      display.c - display_image
  41.        *                  display_menu_for_display_image
  42.        *      mymsc.c - my_clear_text_screen
  43.        *
  44.        *   Modifications:
  45.        *      30 December 1992 - created
  46.        *
  47.        *************************************************/
  48.  
  49. #include "cips.h"
  50.  
  51.  
  52. short the_image[ROWS][COLS];
  53.  
  54. main(argc, argv)
  55.    int argc;
  56.    char *argv[];
  57. {
  58.    char color_transform[80],
  59.         monitor_type[80],
  60.         name[80],
  61.         title[80];
  62.  
  63.    int  display_colors       = 16,
  64.         i                    = 0,
  65.         ie                   = 1,
  66.         il                   = 1,
  67.         image_colors         = 256,
  68.         invert               = 0,
  69.         j                    = 0,
  70.         l                    = 0,
  71.         le                   = COLS+1,
  72.         ll                   = ROWS+1,
  73.         show_hist            = 0;
  74.  
  75.    struct tiff_header_struct image_header;
  76.  
  77.    my_clear_text_screen();
  78.  
  79.    strcpy(name, "d:/pix/adam256.tif");
  80.    strcpy(color_transform, "Straight mode");
  81.    strcpy(monitor_type, "VGA");
  82.    strcpy(title, "");
  83.  
  84.    if(argc == 2  && (strcmp(argv[1], "help") == 0)){
  85.       printf("\nusage: show image-name"
  86.              " [help -i -h -il -ie -t]\n");
  87.       exit(1);
  88.    }  /* ends if show help */
  89.  
  90.    if(argc > 1){
  91.       strcpy(name, argv[1]);
  92.       read_tiff_header(name, &image_header);
  93.       i=2;
  94.       while(i <= argc){
  95.          if(strcmp(argv[i], "-i") == 0)
  96.             invert = 1;
  97.          if(strcmp(argv[i], "-h") == 0)
  98.             show_hist = 1;
  99.          if(strcmp(argv[i], "-il") == 0){
  100.             i++;
  101.             il = atoi(argv[i]);
  102.             ll = il + COLS;
  103.          }
  104.          if(strcmp(argv[i], "-ie") == 0){
  105.             i++;
  106.             ie = atoi(argv[i]);
  107.             le = ie + COLS;
  108.          }
  109.          if(strcmp(argv[i], "-t") == 0){
  110.             i++;
  111.             strcpy(title, " ");
  112.             while(i < argc){
  113.                strcat(title, argv[i]);
  114.                strcat(title, " ");
  115.                i++;
  116.             }
  117.          }
  118.          i++;
  119.       }  /* ends loop over i argc */
  120.  
  121.       display_image(name, the_image, il, ie,
  122.             ll, le, &image_header, monitor_type,
  123.             color_transform, invert,
  124.             image_colors, display_colors,
  125.             show_hist, title);
  126.       exit(2);
  127.    }  /* ends if argc > 2 */
  128.  
  129.  
  130.    get_image_name(name);
  131.    read_tiff_header(name, &image_header);
  132.    get_parameters(&il, &ie, &ll, &le);
  133.    display_menu_for_display_image(&image_colors,
  134.          &display_colors, &invert,
  135.          color_transform, monitor_type,
  136.          &show_hist);
  137.    printf("\nEnter title>");
  138.    gets(title);
  139.    display_image(name, the_image, il, ie,
  140.          ll, le, &image_header, monitor_type,
  141.          color_transform, invert,
  142.          image_colors, display_colors,
  143.          show_hist, title);
  144.  
  145. }  /* ends main */
  146.